﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using dasFX.VSTime.API;

namespace ChartTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                EventSummaryRepository summary = new EventSummaryRepository();
                var data = summary.EventTotalsBySolution(13);

                //VSTimeEntities vste = new VSTimeEntities();
                //var events = from ev in vste.vwEventDuration
                //             where ev.SolutionID == 13
                //             select new 
                //             {
                //                SolutionID = ev.SolutionID,
                //                EventDetail = ev.EventDetail,
                //                TotalMinutes = ev.EventDuration
                //             };
                             

                //var events = from ev in vste.vwSolutionDetail
                //             where ev.SolutionID == 13 && ev.TotalMinutes > 1
                //             select new
                //                        {
                //                            EventDetail = ev.EventDetail,
                //                            TotalMinutes = ev.TotalMinutes
                //                        };

                //var data = events.OrderBy(x => x.TotalMinutes).ToList();

                //chart1.Series["Series1"].Points.DataBind(data, "EventDetail", "TotalMinutes", string.Empty);

                //chart1.ChartAreas["ChartArea1"].CursorX.IsUserEnabled = true;
                //chart1.ChartAreas["ChartArea1"].CursorX.IsUserSelectionEnabled = true;
                //chart1.ChartAreas["ChartArea1"].AxisX.ScaleView.Zoomable = true;

                //chart1.ChartAreas["ChartArea1"].AxisX.ScaleView.Zoom(0, 50);
                //chart1.ChartAreas["ChartArea1"].AxisX.ScaleView.Position = 50;

                //chart1.ChartAreas["ChartArea1"].AxisY.ScrollBar.Size = 10;
                //chart1.ChartAreas["ChartArea1"].AxisY.ScrollBar.IsPositionedInside = true;
                //chart1.ChartAreas["ChartArea1"].AxisX.ScrollBar.Size = 10;
                //chart1.ChartAreas["ChartArea1"].AxisX.ScrollBar.IsPositionedInside = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            
        }
    }
}
